import java.sql.Array;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Random;

public class Util {
   static ArrayList<String> alphabet=new ArrayList<>();
  static int[]number=new int[10];


    //初始化字母与数字
    static public void initAlphabetNumber(){
        for (int i = 0; i < 10; i++) {
            number[i]=i;
        }
        char ch='a';
        int t='A'-'a';
        for (int i = 0; i < 26; i++) {
            Collections.addAll(alphabet,ch+"",(char)(ch+t)+"");
            ch++;
        }
        Collections.shuffle(alphabet);

    }

    //生成验证码
   public  static String code() {
        initAlphabetNumber();
       String code="";
       Random r=new Random();
       int index = r.nextInt(number.length);
       //核心部分
       for (int i = 0; i < 4; i++) {
           if(i==3)
           {
               code += number[index];
               break;
           }
           code+=alphabet.get(i);
       }
       return code;
   }

}